package com.elastic.controller;

import com.alibaba.fastjson.JSONObject;
import com.elastic.domain.GeoSearch;
import com.elastic.service.GeoSearchService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("/geoSearch")
public class GeoSearchController {

    @Resource
    private GeoSearchService service;

    @RequestMapping(value = "/search",method = RequestMethod.POST)
    public JSONObject geoSearch(@RequestBody GeoSearch search) throws Exception{
        JSONObject output = new JSONObject();
        JSONObject result = service.geoSearch(search);
        if (result.get("msg") == "succeed") {
            output.put("msg" ,"succeed");
            output.put("data", result.get("data"));
        } else {
            output.put("msg", "failed");
            output.put("data", result.get("data"));
        }
        return output;
    }

}